<?php
/**
 * Zend Framework Contribution
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Mwb
 * @copyright  Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    1.0 Layer.php 3 mai 2012 Sergio DE VASCONCELOS
 */

require_once('Zend/Mwb/Dom/Abstract.php');

/**
 * MySQL Workbench document
 *
 * @category   Zend
 * @package    Zend_Mwb
 */
class Zend_Mwb_Dom_Layer extends Zend_Mwb_Dom_Abstract
{
	/**
	 * @var String $name
	 */
	protected $name;
	/**
	 * @var Zend_Mwb_Dom_Figure
	 */
	protected $owner;
	/**
	 * @return String $name
	 */
	public function getName() {
		if (is_null($this->name)) {
			$this->name = $this->loadName();
		}
		return $this->name;
	}
	/**
	 * @param String $name
	 * @return Zend_Mwb_Dom_Layer
	 */
	public function setName($name) {
		$this->name = $name;
		return $this;
	}
	protected function loadName() {
		$xpath = new DOMXPath($this->node->ownerDocument);
    	$element = $xpath->query("value[@key='name']", $this->node)->item(0);
    	if (isset($element)) {
        	return $element->textContent;
        } else {
        	require_once 'Zend/Mwb/Exception.php';
        	throw new Zend_Mwb_Exception('Dom_Exception_Null($this->node)');
        }
	}
	/**
	 * @return Owner
	 */
	public function getOwner() {
		if (is_null($this->owner)) {
			$this->owner = $this->loadOwner();
		}
		return $this->owner;
	}
	/**
	 * @param Zend_Mwb_Dom_FigureTable
	 * @return Zend_Mwb_Dom_Layer
	 */
	public function setOwner($owner) {
		$this->owner = $owner;
		return $this;
	}
	protected function loadOwner() {
		$xpath = new DOMXPath($this->node->ownerDocument);
    	$element = $xpath->query("value[@key='owner']", $this->node)->item(0);
    	if (isset($element)) {
        	return $element->textContent;
        } else {
        	require_once 'Zend/Mwb/Exception.php';
        	throw new Zend_Mwb_Exception('Dom_Exception_Null($this->node)');
        }
	}
}

/*
<value type="object" struct-name="workbench.physical.Layer" id="4e586f30-9d3e-11e1-9337-5404a6bea04e" struct-checksum="0x1d14ca4b">
    <value type="string" key="color">#F0F1FE</value>
    <value type="string" key="description"></value>
    <value _ptr_="0x7f9acc12cb40" type="list" content-type="object" content-struct-name="model.Figure" key="figures"/>
    <value _ptr_="0x7f9acc12d680" type="list" content-type="object" content-struct-name="model.Group" key="groups"/>
    <value type="real" key="height">2.39e+02</value>
    <value type="real" key="left">5.9e+02</value>
    <value _ptr_="0x7f9acc141f40" type="list" content-type="object" content-struct-name="model.Layer" key="subLayers"/>
    <value type="real" key="top">2.98e+02</value>
    <value type="real" key="width">3.03e+02</value>
    <link type="object" struct-name="model.Diagram" key="owner">fc1b8fe6-9bc5-11e1-82d2-5404a6bea04e</link>
    <value type="int" key="visible">1</value>
	<value type="string" key="name">Sergio</value>
</value>
 */
